package cn.signalpha.modules.com.excel.converter;

import cn.signalpha.core.tool.utils.SpringUtil;
import cn.signalpha.modules.com.entity.UserLevel;
import cn.signalpha.modules.com.service.UserLevelService;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

/**
 * 类说明
 *
 * @author suguangjun
 */
public class UserLevelConverter implements Converter<Integer> {

	private static final UserLevelService userLevelService;

	static {
		userLevelService = SpringUtil.getBean(UserLevelService.class);
	}

	@Override
	public Class supportJavaTypeKey() {
		return null;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return null;
	}

	@Override
	public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) {
		return null;
	}

	@Override
	public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) {
		UserLevel userLevel = userLevelService.getById(integer);
		return new CellData(userLevel == null ? "" : userLevel.getName());
	}

//	@Override
//	public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) {
//		UserLevelEnum userLevelEnum = UserLevelEnum.instance(integer);
//		return new CellData(userLevelEnum == null ? "" : userLevelEnum.getValue());
//	}
}
